
#include "rangecircle.h"
#include "gamemanager.h"
#include "levelmanager.h"
#include "resourcemanager.h"

RangeCircle::RangeCircle()
{
}

RangeCircle::~RangeCircle() {

}

bool RangeCircle::init() {
	if ( !Sprite::init() ){
		return false;
	}

	setDisplayFrame(CREATE_SPRITEFRAME("textures/ui/round_button_0.png"));
	setScale(GM->minscale);
	setAnchorPoint(Point(0.5f, 0.5f));

	for(int i = 0; i < 8; i++) {
		Sprite* spr = CREATE_SPRITE("textures/units/range_circle.png");
		spr->setScale(1.0f);
		spr->setAnchorPoint(Point::ZERO);
		spr->setRotation(i * 45.0f);
		spr->setPosition(Point::ZERO);
		
		addChild(spr);
	}

	return true;
}

void RangeCircle::changeSize( float width )
{
	setContentSize(Size(width, width));
	setScaleX(GM->minscale);
	setScaleY(GM->minscale * 0.7f);
}

RangeCircle* RangeCircle::create()
{
	RangeCircle* r = new RangeCircle();
	if(r && r->init()) {
		r->autorelease();
	} else {
		CC_SAFE_DELETE(r);
	}

	return r;
}
